package com.tedu.ivos.audit.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.tedu.ivos.audit.pojo.dto.AuditQuery;
import com.tedu.ivos.audit.pojo.dto.AuditSaveParam;
import com.tedu.ivos.audit.pojo.vo.AuditVO;
import com.tedu.ivos.audit.service.AuditService;
import com.tedu.ivos.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "审批单模块")
@RequestMapping("/v1/audit/")
public class AuditController {

    @Autowired
    private AuditService auditService;

    @ApiOperation("1.查询审批单")
    @ApiOperationSupport(order = 10)
    @PostMapping("select")
    public JsonResult selectAuditList(AuditQuery auditQuery) {
        log.debug("查询审批单,{}", auditQuery);
        List<AuditVO> list = auditService.selectAudit(auditQuery);

        return JsonResult.ok(list);
    }

    @ApiOperation("2.查询审批单")
    @ApiOperationSupport(order = 20)
    @PostMapping("update")
    public JsonResult updateAudit(AuditSaveParam auditSaveParam){
        log.debug("更新审批单:{}",auditSaveParam);
        auditService.updateAudit(auditSaveParam);

        return JsonResult.ok();
    }
}
